package 剑指offer;

public class 剑指offer24反转链表 {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null){
            return head;
        }
        ListNode cur = head;
        ListNode next = null;
        ListNode temp = new ListNode(1);
        while (cur != null){
            next = cur.next;
            cur.next = temp.next;
            temp.next = cur;
            cur = next;
        }
        return temp;
    }
}
